package org.wmq.travelagency02.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.wmq.travelagency02.mapper.ContactMapper;
import org.wmq.travelagency02.model.Entity.ChatUser;
import org.wmq.travelagency02.model.Entity.Contact;
import org.wmq.travelagency02.service.ContactService;

import java.util.List;

@Service
@RequiredArgsConstructor
public class ContactServiceImpl extends ServiceImpl<ContactMapper, Contact> implements ContactService {
    private final ContactMapper contactMapper;

    @Override
    public void removeByMasterIdAndSlaveId(String masterId, String slaveId) {
        this.lambdaUpdate().eq(Contact::getMasterId,masterId)
                .eq(Contact::getSlaveId, slaveId)
                .remove();
    }

    @Override
    public void removeByMasterId(String masterId) {
        this.lambdaUpdate().eq(Contact::getMasterId,masterId).remove();
    }

    @Override
    public List<ChatUser> getContactList(String masterId) {
        return this.contactMapper.getContactList(masterId);
    }
}
